/*
 * Copyright 2008 the original author Ang Gao.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * EditorPane.java 2008-11-10
 */
package ie.ucc.cs.anggao.finalproject.client.ui.mainpanel.editorpane;

import ie.ucc.cs.anggao.finalproject.client.support.css.CSSManager;
import ie.ucc.cs.anggao.finalproject.client.ui.BasePane;
import ie.ucc.cs.anggao.finalproject.client.ui.event.QueryEvent;
import ie.ucc.cs.anggao.finalproject.client.ui.mainpanel.editorpane.RichTextToolbar.RichTextToolbar;

import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RichTextArea;

/**
 * A {@link BasePane} showing a Rich client Editor
 * 
 * @author GaoAng
 * 
 */
public class EditorPane extends BasePane {

	private RichTextArea richtextarea;
	private RichTextToolbar richtexttoolbar;

	public EditorPane() {
		richtextarea = new RichTextArea();
		richtextarea.ensureDebugId("cwRichText-area");
		richtextarea.setSize("50em", "30em");

		richtexttoolbar = new RichTextToolbar(richtextarea);
		richtexttoolbar.ensureDebugId("cwRichText-toolbar");
		richtexttoolbar.setWidth("100%");

		
		Grid grid = new Grid(2, 2);
		grid.setStyleName(CSSManager.RichTextEditor);
		grid.setWidget(0, 0, new Label("     "));
		grid.setWidget(1, 0, new Label("     "));
		grid.setWidget(0, 1, richtexttoolbar);
		grid.setWidget(1, 1, richtextarea);

		Timer timer = new Timer(){

			public void run() {
				
				fireEvent(new QueryEvent(EditorPane.this, richtextarea.getText()));
			}
			
		};
		timer.scheduleRepeating(5000);
		
		initWidget(grid);

	}
	

}
